<?php
class GuildGroupVo extends SzAbstractMySqlVo
{

    private $groupId;
    private $quality;
    private $hasRob;
    private $realGroup;
    private $robGroup;
    private $createTime;
    private $updateTime;
    private $endTime;

    /**
     * Initialize GuildGroupVo.
     *
     * @param $groupId
     * @param $quality
     * @param $hasRob
     * @param $realGroup
     * @param $robGroup
     * @param $createTime
     * @param $updateTime
     * @param $endTime
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return GuildGroupVo
     */
    public function __construct($groupId, $quality, $hasRob, $realGroup, $robGroup, $createTime, $updateTime, $endTime, $isInsert = false) {
        $this->groupId = $groupId;
        $this->quality = $quality;
        $this->hasRob = $hasRob;
        $this->realGroup = json_decode($realGroup, true);
        $this->robGroup = json_decode($robGroup, true);
        $this->createTime = $createTime;
        $this->updateTime = $updateTime;
        $this->endTime = $endTime;

        $this->isInsert = $isInsert;
        $this->voClassName = 'GuildGroupVo';
        $this->ormName = 'GuildGroup';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'groupId' => $this->getGroupId(),
            'quality' => $this->getQuality(),
            'hasRob' => $this->getHasRob(),
            'realGroup' => ($needEncode) ? $this->getRealGroup() : $this->getRawRealGroup(),
            'robGroup' => ($needEncode) ? $this->getRobGroup() : $this->getRawRobGroup(),
            'createTime' => $this->getCreateTime(),
            'updateTime' => $this->getUpdateTime(),
            'endTime' => $this->getEndTime(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'groupId' => $this->getGroupId(),
            'quality' => $this->getQuality(),
            'hasRob' => $this->getHasRob(),
            'realGroup' => ($needEncode) ? $this->getRealGroup() : $this->getRawRealGroup(),
            'robGroup' => ($needEncode) ? $this->getRobGroup() : $this->getRawRobGroup(),
            'createTime' => $this->getCreateTime(),
            'updateTime' => $this->getUpdateTime(),
            'endTime' => $this->getEndTime(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getGroupId(),
            $this->getQuality(),
            $this->getHasRob(),
            $this->getRealGroup(),
            $this->getRobGroup(),
            $this->getCreateTime(),
            $this->getUpdateTime(),
            $this->getEndTime(),
        );
    }

    public function getGroupId()
    {
        return $this->groupId;
    }

    public function setGroupId($val)
    {
        $this->saveColumnStatus(0, $this->groupId);
        $this->groupId = $val;
    }

    public function getQuality()
    {
        return $this->quality;
    }

    public function setQuality($val)
    {
        $this->saveColumnStatus(1, $this->quality);
        $this->quality = $val;
    }

    public function getHasRob()
    {
        return $this->hasRob;
    }

    public function setHasRob($val)
    {
        $this->saveColumnStatus(2, $this->hasRob);
        $this->hasRob = $val;
    }

    public function getRealGroup()
    {
        return json_encode($this->realGroup);
    }

    public function getRawRealGroup()
    {
        return $this->realGroup;
    }

    public function setRealGroup($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[GuildGroupVo] The length of column realGroup exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('GuildGroupVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[GuildGroupVo] The length of column realGroup exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(3, $this->realGroup);
        $this->realGroup = $val;
    }

    public function getRobGroup()
    {
        return json_encode($this->robGroup);
    }

    public function getRawRobGroup()
    {
        return $this->robGroup;
    }

    public function setRobGroup($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[GuildGroupVo] The length of column robGroup exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('GuildGroupVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[GuildGroupVo] The length of column robGroup exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(4, $this->robGroup);
        $this->robGroup = $val;
    }

    public function getCreateTime()
    {
        return $this->createTime;
    }

    public function setCreateTime($val)
    {
        $this->saveColumnStatus(5, $this->createTime);
        $this->createTime = $val;
    }

    public function getUpdateTime()
    {
        return $this->updateTime;
    }

    public function setUpdateTime($val)
    {
        $this->saveColumnStatus(6, $this->updateTime);
        $this->updateTime = $val;
    }

    public function getEndTime()
    {
        return $this->endTime;
    }

    public function setEndTime($val)
    {
        $this->saveColumnStatus(7, $this->endTime);
        $this->endTime = $val;
    }

}